/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package typinggame;

import java.util.ArrayList;

/**
 *
 * @author suhui
 */
public class GameInfo {

    class player{
        String playername;
        int playerlevel;
        int playerexp;

        player(String name, int level, int exp)
        {
            this.playername = name;
            this.playerlevel = level;
            this.playerexp = exp;
        }
        player(String name, int level)
        {
            this.playername = name;
            this.playerlevel = level;
            //this.playerexp = exp;
        }
    }

    int maxwordsize;

    int expgained;
    int intercepted;
    int hits;
    int teamhits;
    int damage;
    player p;

    ArrayList<player> myteam = new ArrayList();
    ArrayList<player> enemyteam = new ArrayList();

    GameInfo(String name, int level, int exp)
    {
        p = new player(name,level,exp);

        this.maxwordsize = 3 + level;
        if(this.maxwordsize>13)
            this.maxwordsize = 13;
        this.expgained = 0;
        //this.words_fired = 0;
        this.hits=0;
        this.teamhits=0;
        this.damage = 0;
    }
    public void populatemyteam(String name, int level)
    {
        player p = new player(name,level);
        myteam.add(p);
    }
    public void populateotherteam(String name, int level)
    {
        player p = new player(name,level);
        enemyteam.add(p);
    }
    public boolean inmyteam(String name)
    {
        for(int i = 0; i<myteam.size(); i++)
            if(myteam.get(i).playername.equals(name))
                return true;
        return false;
    }
    public String getplayer()
    {
        return p.playername;
    }
    public int getplayerlevel()
    {
        return p.playerlevel;
    }
    public void update(int newhits, int newdamage, int newthit, int levelbonus)
    {
        //this.words_fired += characters;
        this.hits += newhits;
        this.damage += newdamage;
        this.teamhits += newthit;
        this.expgained = hits * 2  + teamhits *1 - damage * levelbonus;
        if(expgained <0)
            expgained = 0;

    }
    public void interceptpts(int wordlength, int levelbonus)
    {
        this.intercepted += wordlength;
        this.expgained += wordlength * levelbonus;
    }
    private double getbonus(int level)
    {
        return level * 0.1 + 1;
    }


}
